/**
 * fileName:  ArgumentWriter.java
 * author:  Pitaya
 * Company:  Cloudland Studio
 * Createdate:  2014-6-5 下午10:35:34
 *
 * All rights Reserved, Designed By cloudland Copyright(C) 2010-2011
 *   
 * Modification  History:
 *     Date           Author        Version        
 * -------------------------------------------
 * 2014-6-5            Pitaya            1.0        
 *
 * Why & What is modified:
 * 1.0: 文件创建
 */
package org.cloudland.commercial.masterdata.store.write;

import javax.annotation.Resource;

import org.cloudland.commercial.masterdata.store.DatabaseWrite;
import org.cloudland.commercial.masterdata.store.entity.ArgumentEntity;
import org.cloudland.jdbc.ibatis.masterdata.entity.FruitArgumentEntity;
import org.cloudland.jdbc.ibatis.masterdata.handler.FruitArgumentMapper;
import org.cloudland.util.Randoms;
import org.springframework.stereotype.Service;

 /**
 * <pre> 
 * TODO 请充分描述该类提供的作用, 或与其他类会有关联的使用。
 * 使用 java.lang.Object#toString(), 或者 {@link java.lang.Character Character} 等标签
 * </pre>
 * @ClassName  ArgumentWriter
 * @author  Pitaya
 * @version  %I%, %G%
 * @see  
 * @since   JDK1.6
 *
 */
@Service
public class ArgumentWriter implements DatabaseWrite<ArgumentEntity> {
	
	@Resource(name = "fruitArgumentMapper")
	private FruitArgumentMapper argumentMapper;
	
	/**
	 * <pre>
	 * TODO 请充分描述该构造函数的作用，及其参数的作用。
	 * </pre>
	 *   
	 */
	public ArgumentWriter() {
		// TODO Auto-generated constructor stub
	}

	/**
	 * 添加水果参数信息
	 * @param entity
	 */
	public void save(ArgumentEntity entity) {
		String uuid = Randoms.uuid();
		short sort = Short.parseShort(entity.getSort().toString());
		entity.setArgumentId(uuid);
		FruitArgumentEntity daoEntity = new FruitArgumentEntity(entity.getArgumentId(), entity.getArgumentName(), entity.getDescribtion(), sort);
		argumentMapper.add(daoEntity);
	}

	/** 修改水果参数信息
	 * @param entity
	 */
	public void update(ArgumentEntity entity) {
		short sort = Short.parseShort(entity.getSort().toString());
		FruitArgumentEntity daoEntity = new FruitArgumentEntity(entity.getArgumentId(), entity.getArgumentName(), entity.getDescribtion(), sort);
		argumentMapper.update(daoEntity);
	}

	/**
	 * 删除水果参数信息
	 * @param entity
	 */
	public void delete(ArgumentEntity entity) {
		
	}
	
	public boolean delArgumentInfo(ArgumentEntity entity)
	{
		FruitArgumentEntity daoEntity = new FruitArgumentEntity();
		daoEntity.setId(entity.getArgumentId());
		Integer rtn = argumentMapper.delete(daoEntity);
		if(rtn > 0)
		{
			return true;
		}
		return false;
	}

}
